﻿using System;
using Artem.Google.UI;

namespace mojoPortal.Web.RS.SBM.Components.GoogleMap
{
    public partial class GoogleMapControl : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadMap();
        }


        private void LoadMap()
        {
            //GoogleMap1.Markers.Add(new Marker { Position = new LatLng(42.1229, 24.7879) });
            //GoogleMap1.Markers.Add(new Marker { Position = new LatLng(42.7, 23.3) });

            Marker m = new Marker();
            m.Address = "3257 South Bay Drive, Jonesboro, GA 30236";
            m.Title = "Appollo lives here";
            m.Info = "this is INFO";
            GoogleMap1.Markers.Add(m);
        }

        public void PopulateMapMarker()
        {
            //if (WorkOrderstatusid == 0)
            //    WorkOrderstatusid = 4;
            //int WorkOrderid = 0;
            //String strSQL = "SELECT * FROM rs_vwLocationWithWorkOrder WHERE WorkOrderStatusId=@WorkOrderStatusId AND CompanyId=@CompanyId";
            //SqlCommand myCommand;
            //SqlParameter param;
            //SqlConnection myConnection;
            //myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings[RSCommonFunctions.GetRSCompanyConnectionString()].ToString());
            //myCommand = new SqlCommand(strSQL, myConnection);
            //SqlDataReader myDataReader;
            //param = new SqlParameter();
            //param.SqlDbType = SqlDbType.Int;
            //param.ParameterName = "@WorkOrderstatusid";
            //param.Value = WorkOrderstatusid;
            //myCommand.Parameters.Add(param);

            //param = new SqlParameter();
            //param.SqlDbType = SqlDbType.Int;
            //param.ParameterName = "@companyid";
            //param.Value = companyid;
            //myCommand.Parameters.Add(param);

            //myConnection.Open();
            //myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
            //if (myDataReader.HasRows)
            //{
            //    while (myDataReader.Read())
            //    {
            //        WorkOrderid = int.Parse(myDataReader["workorderid"].ToString());
            //        MapMarker mm = new MapMarker(WorkOrderid);
            //        //if(myDataReader["Longitude"] != DBNull.Value)
            //        //    mm.Longitude = myDataReader["Longitude"].ToString();
            //        //if (myDataReader["Latitude"] != DBNull.Value)
            //        //    mm.Latitude = myDataReader["Latitude"].ToString();
            //        if (myDataReader["Location"] != DBNull.Value)
            //            mm.Address = myDataReader["Location"].ToString();
            //        if (myDataReader["WorkOrderName"] != DBNull.Value)
            //            mm.AdditionalDescription = myDataReader["WorkOrderName"].ToString();

            //        if (myDataReader["workorderid"] != DBNull.Value)
            //            mm.QuickLink = "WorkOrderID: " + myDataReader["workorderid"].ToString();
            //        if (myDataReader["WorkOrderName"] != DBNull.Value)
            //            mm.QuickLink = mm.QuickLink + " - " + myDataReader["WorkOrderName"].ToString();

            //        if (myDataReader["workorderid"] != DBNull.Value)
            //            mm.BubbleTitle = "WorkOrderID: " + myDataReader["workorderid"].ToString();
            //        if (myDataReader["WorkOrderName"] != DBNull.Value)
            //            mm.BubbleTitle = mm.BubbleTitle + " - " + myDataReader["WorkOrderName"].ToString();

            //        if (myDataReader["WorkOrderName"] != DBNull.Value)
            //            mm.BubbleDescription = myDataReader["WorkOrderName"].ToString();
            //        if (myDataReader["Location"] != DBNull.Value)
            //            mm.BubbleDescription = mm.BubbleDescription + "<br/>" + myDataReader["Location"].ToString();
            //        if (myDataReader["AssignTo"] != DBNull.Value)
            //            mm.BubbleDescription = mm.BubbleDescription + "<br/>" + myDataReader["AssignTo"].ToString();

            //        lstMarkers.Add(mm);
            //    }
            //}
            //myConnection.Close();
        }
    }
}